package com.zjq.authoritysystem.vo.result;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

/**
 * @author BetOnMe
 * @version 1.0
 * @ClassName Result
 * @description: TODO
 * @since 2023年09月11日 22:33:23
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
public class Result {
    private Integer code;
    private String msg;
    private Object data;

    public Result(Integer code, String msg) {
        this.code = code;
        this.msg = msg;
    }

    public Result(Integer code, Object data) {
        this.code = code;
        this.data = data;
    }

    public Integer getCode() {
        return code;
    }

    public void setCode(Integer code) {
        this.code = code;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public Object getData() {
        return data;
    }

    public void setData(Object data) {
        this.data = data;
    }

    public static Result SUCCESS() {
        return new Result(ResultCode.SUCCESS.getCode(), ResultCode.SUCCESS.getMsg(), "ok");
    }

    public static Result SUCCESS(Object data) {
        return new Result(ResultCode.SUCCESS.getCode(), ResultCode.SUCCESS.getMsg(), data);
    }

    public static Result TIO_ERROR(String msg) {
        return new Result(ResultCode.TIP_ERROR.getCode(), msg, null);
    }

    public static Result TIO_ERROR(String msg, Object data) {
        return new Result(ResultCode.TIP_ERROR.getCode(), msg, data);

    }

    public static Result Error(String msg) {
        return new Result(ResultCode.ERROR.getCode(), msg);
    }

    /**
     * 返回失败
     *
     * @param code 状态码
     * @param msg  返回消息
     * @return 消息
     */
    public static Result Error(Integer code, String msg) {
        return new Result(code, msg);
    }

}
